package com.server.process.service;

import com.server.common.utils.IdWorker;
import com.server.domain.process.WorkFlow;
import com.server.process.dao.WorkFlowDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkFlowService {
    @Autowired
    private WorkFlowDao workFlowDao;
    @Autowired
    private IdWorker idWorker;

    /**
     * 构建新工作流
     */
    public void add(WorkFlow workFlow){
        String id = idWorker.nextId() + "";
        workFlow.setId(id);
        workFlowDao.save(workFlow);
    }
    /**
     * 根据companyId查询工作流列表
     */
    public List<WorkFlow> findByCompanyId(String companyId){
        return workFlowDao.findByCompanyId(companyId);
    }
    /**
     * 根据工作流id查询工作流
     */
    public WorkFlow findById(String id){
        return workFlowDao.findById(id).get();
    }
}
